// CESPubOp
log using CESPubOp.log, replace

use "C:\Users\sbstjp\OneDrive - Cardiff University\CES24_Common.dta" // Schaffner, Brian; Shih, Marissa; Ansolabehere, Stephen; Pope, Jeremy, 2025, "Cooperative Election Study Common Content, 2024", https://doi.org/10.7910/DVN/X11EP6, Harvard Dataverse, V3. Accessed on 12 April 2025.

*Rename questions
rename CC24_321e defund
rename CC24_444a gendertransition
rename CC24_444b parentalconsentpronouns 
rename CC24_445a raceuniadmissions

// Demographics
*Delete missing values and rename
replace gender4=. if gender4>2
rename gender4 FemaleGender

generate age = 2024 - birthyr

replace CC24_330a=. if CC24_330a==8 
rename CC24_330a libconsp

*Create dummies
gen Graduate=.
replace Graduate=0 if inrange(educ, 1, 4)
replace Graduate=1 if inlist(educ, 5, 6)

gen BIPOC=.
replace BIPOC=0 if race==1
replace BIPOC=1 if inrange(race, 2, 8)

// The results
tab defund [aweight=commonweight]
tab defund if libconsp < 4 [aweight=commonweight]
tab defund if libconsp > 4 [aweight=commonweight]
tab defund if Graduate==0 [aweight=commonweight]
tab defund if Graduate==1 [aweight=commonweight]
tab defund if BIPOC==0 [aweight=commonweight]
tab defund if BIPOC==1 [aweight=commonweight]
tab defund if FemaleGender==1 [aweight=commonweight]
tab defund if FemaleGender==2 [aweight=commonweight]
tab defund if age<35 [aweight=commonweight]
tab defund if age>=35 & age<=59 [aweight=commonweight]
tab defund if age>59 [aweight=commonweight]

tab gendertransition [aweight=commonpostweight]
tab gendertransition if libconsp < 4 [aweight=commonpostweight]
tab gendertransition if libconsp > 4 [aweight=commonpostweight]
tab gendertransition if Graduate==0 [aweight=commonpostweight]
tab gendertransition if Graduate==1 [aweight=commonpostweight]
tab gendertransition if BIPOC==0 [aweight=commonpostweight]
tab gendertransition if BIPOC==1 [aweight=commonpostweight]
tab gendertransition if FemaleGender==1 [aweight=commonpostweight]
tab gendertransition if FemaleGender==2 [aweight=commonpostweight]
tab gendertransition if age<35 [aweight=commonpostweight]
tab gendertransition if age>=35 & age<=59 [aweight=commonpostweight]
tab gendertransition if age>59 [aweight=commonpostweight]

tab parentalconsentpronouns [aweight=commonpostweight]
tab parentalconsentpronouns if libconsp < 4 [aweight=commonpostweight]
tab parentalconsentpronouns if libconsp > 4 [aweight=commonpostweight]
tab parentalconsentpronouns if Graduate==0 [aweight=commonpostweight]
tab parentalconsentpronouns if Graduate==1 [aweight=commonpostweight]
tab parentalconsentpronouns if BIPOC==0 [aweight=commonpostweight]
tab parentalconsentpronouns if BIPOC==1 [aweight=commonpostweight]
tab parentalconsentpronouns if FemaleGender==1 [aweight=commonpostweight]
tab parentalconsentpronouns if FemaleGender==2 [aweight=commonpostweight]
tab parentalconsentpronouns if age<35 [aweight=commonpostweight]
tab parentalconsentpronouns if age>=35 & age<=59 [aweight=commonpostweight]
tab parentalconsentpronouns if age>59 [aweight=commonpostweight]

tab raceuniadmissions [aweight=commonpostweight]
tab raceuniadmissions if libconsp < 4 [aweight=commonpostweight]
tab raceuniadmissions if libconsp > 4 [aweight=commonpostweight]
tab raceuniadmissions if Graduate==0 [aweight=commonpostweight]
tab raceuniadmissions if Graduate==1 [aweight=commonpostweight]
tab raceuniadmissions if BIPOC==0 [aweight=commonpostweight]
tab raceuniadmissions if BIPOC==1 [aweight=commonpostweight]
tab raceuniadmissions if FemaleGender==1 [aweight=commonpostweight]
tab raceuniadmissions if FemaleGender==2 [aweight=commonpostweight]
tab raceuniadmissions if age<35 [aweight=commonpostweight]
tab raceuniadmissions if age>=35 & age<=59 [aweight=commonpostweight]
tab raceuniadmissions if age>59 [aweight=commonpostweight]

log close
